#include <stdio.h>
#include <time.h>
#include "sm4_bs.h"

unsigned __int64 ukeyh[16]={0x0000000000000000,0x2222222222222222,0x4444444444444444,0x6666666666666666,0x8888888888888888,0xAAAAAAAAAAAAAAAA,0xCCCCCCCCCCCCCCCC,0xEEEEEEEEEEEEEEEE,0xFFFFFFFFFFFFFFFF,0xDDDDDDDDDDDDDDDD,0xBBBBBBBBBBBBBBBB,0x9999999999999999,0x7777777777777777,0x5555555555555555,0x3333333333333333,0x1111111111111111};
unsigned __int64 ukeyl[16]={0x1111111111111111,0x3333333333333333,0x5555555555555555,0x7777777777777777,0x9999999999999999,0xBBBBBBBBBBBBBBBB,0xDDDDDDDDDDDDDDDD,0xFFFFFFFFFFFFFFFF,0xEEEEEEEEEEEEEEEE,0xCCCCCCCCCCCCCCCC,0xAAAAAAAAAAAAAAAA,0x8888888888888888,0x6666666666666666,0x4444444444444444,0x2222222222222222,0x0000000000000000};
unsigned __int64 inh[16]={0x0000000000000000,0x2222222222222222,0x4444444444444444,0x6666666666666666,0x8888888888888888,0xAAAAAAAAAAAAAAAA,0xCCCCCCCCCCCCCCCC,0xEEEEEEEEEEEEEEEE,0xFFFFFFFFFFFFFFFF,0xDDDDDDDDDDDDDDDD,0xBBBBBBBBBBBBBBBB,0x9999999999999999,0x7777777777777777,0x5555555555555555,0x3333333333333333,0x1111111111111111};
unsigned __int64 inl[16]={0x1111111111111111,0x3333333333333333,0x5555555555555555,0x7777777777777777,0x9999999999999999,0xBBBBBBBBBBBBBBBB,0xDDDDDDDDDDDDDDDD,0xFFFFFFFFFFFFFFFF,0xEEEEEEEEEEEEEEEE,0xCCCCCCCCCCCCCCCC,0xAAAAAAAAAAAAAAAA,0x8888888888888888,0x6666666666666666,0x4444444444444444,0x2222222222222222,0x0000000000000000};

void main()
{
	clock_t t1,t2;
	unsigned int p; 
	int i,j;
	sms4_key_t_bs keybs;

	printf("pai:\n");
	scanf("%d",&p);
	sms4_set_encrypt_key_bs(&keybs,ukeyh,ukeyl);
	t1 = clock();
	for(i=0;i<p;i++)
	{
		SMS4_encrypt_bs(&keybs,inh,inl,inh,inl);
	}
	t2 = clock();
	printf(" %f %f %f B/s\n",(double)(t2-t1)/CLOCKS_PER_SEC,(16.0*p)/((double)(t2-t1)/CLOCKS_PER_SEC),(16.0*p*16)/((double)(t2-t1)/CLOCKS_PER_SEC));
	for(j=0;j<16;j++){for(i=0;i<16;i++){printf("%x%x,",(unsigned char)(inh[i]>>j*4)&0xf,(unsigned char)(inl[i]>>j*4)&0xf);}printf("\n");}
	//68,1e,df,34,d2,06,96,5e,86,b3,e9,4f,53,6e,42,46,
}